﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Ooganizer.Platform;
using Ooganizer.Server;

namespace Ooganizer.Client.UI
{
    /// <summary>
    /// Interaction logic for ButtonFormPage_Add.xaml
    /// </summary>
    public partial class ButtonFormPage_Add : Page
    {
        // The Parent needs to set this before we are being shown
        public ButtonForm ParentWPFContainer { get { return _ButtonForm; } set { _ButtonForm = value; } }
        private ButtonForm _ButtonForm = null;

        public ButtonFormPage_Add()
        {
            InitializeComponent();
        }

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (ParentWPFContainer == null)
            {
                Log.Debug(string.Format("{0}() - ParentWPFContainer is null!",
                          System.Reflection.MethodBase.GetCurrentMethod().Name));

                return;
            }

            // Set the Artifact Properties 
            txtTitle.Text = ParentWPFContainer.ArtifactTitle;
            txtLocation.Text = ParentWPFContainer.ArtifactLocation;
            
            // Also set the current workspace - To Do (needs to actually get all workspaces)
            comboWorkspaces.Items.Add(ParentWPFContainer.CurrentWorkspaceName);
            comboWorkspaces.SelectedIndex = 0;
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            // We are done here, tell the parent to close
            ParentWPFContainer.Close();
        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {

        }

        #region log4net declaration

        private log4net.ILog Log
        {
            get
            {
                if (_logWrapper == null)
                {
                    _logWrapper = new LogServerClientWrapper(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
                }

                return _logWrapper.Log;
            }
        }

        private LogServerClientWrapper _logWrapper;

        #endregion
    }
}
